package com.example.administrator.managesystem.broadcast;

import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.text.format.DateFormat;
import android.view.View;

import com.example.administrator.managesystem.base.MyApplication;
import com.example.administrator.managesystem.utils.ActivityUtils;
import com.videogo.errorlayer.ErrorInfo;
import com.videogo.exception.BaseException;
import com.videogo.exception.ErrorCode;
import com.videogo.openapi.bean.EZDeviceInfo;
import com.videogo.util.ConnectionDetector;
import com.videogo.util.LogUtil;
import com.videogo.util.Utils;

import java.util.Date;
import java.util.List;

/**
 * 获取事件消息任务
 */
public class GetCamersInfoListTask extends AsyncTask<Void, Void, List<EZDeviceInfo>> {
    private boolean mHeaderOrFooter;
    private int mErrorCode = 0;

    private final static int LOAD_MY_DEVICE = 0;
    private final static int LOAD_SHARE_DEVICE = 1;
    private int mLoadType = LOAD_MY_DEVICE;
    private Context context;

    public GetCamersInfoListTask( Context context) {
        this.context = context;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
//        //mListView.setFooterRefreshEnabled(true);
//        if (mHeaderOrFooter) {
//            mListView.setVisibility(View.VISIBLE);
//            mNoCameraTipLy.setVisibility(View.GONE);
//            mGetCameraFailTipLy.setVisibility(View.GONE);
//        }
//        mListView.getRefreshableView().removeFooterView(mNoMoreView);
    }

    @Override
    protected List<EZDeviceInfo> doInBackground(Void... params) {


        List<EZDeviceInfo> result = null;


            try {
                result = MyApplication.getOpenSDK().getDeviceList(0, 20);
            } catch (Exception e) {
                e.printStackTrace();
            }


            return result;


    }
    @Override
    protected void onPostExecute(List<EZDeviceInfo> result) {
        super.onPostExecute(result);


        if (result != null) {
          //  addCameraList(result);
        }

        if (mErrorCode != 0) {
            onError(mErrorCode);
        }
    }

    protected void onError(int errorCode) {
        switch (errorCode) {
            case ErrorCode.ERROR_WEB_SESSION_ERROR:
            case ErrorCode.ERROR_WEB_SESSION_EXPIRE:
              //  ActivityUtils.handleSessionException(context);
                break;
            default:
                break;
        }
    }
}
